#ifndef RUNTIME_HPP_GUARD_
#define RUNTIME_HPP_GUARD_

#include "bobox_runtime.hpp"
#include "bobox_request.hpp"
#include "bobox_results.hpp"
#include "boxes.hpp"

class results : public bobox::results {
	virtual size_t get_tables_count() const
	{
		return 0;
	}

	virtual size_t get_rows_count(size_t table) const
	{
		return 0;
	}
		
	virtual void get_rows(size_t table, size_t from, size_t count, rows_type &rows) const
	{
	}
};

class request : public bobox::request {
public:

	request(bobox::request_id_type rqid, bobox::runtime *rt, bobox::box_model *model)
		: bobox::request(rqid, rt, model)
	{}

	virtual const bobox::results *get_results() const { return &results_; }

private:

	results results_;
};

class runtime : public bobox::runtime {

private:
	virtual void init_impl(const bofe::configuration &conf) {}
	virtual void destroy_impl() {}

	virtual bobox::request *create_request_impl(const std::string &model, bobox::request_id_type rqid)
	{
		return new request(rqid, this, 
            new bobox::model_box_model(bobox::box_model_id_type(0), 
                bobox::box_tid_type("model_box"), model, this));
	}

	virtual bobox::box_model_ptr_type create_box_model_impl(bobox::box_model_id_type id, 
        bobox::box_tid_type tid, const bobox::parameters &params)
	{
		if (tid == bobox::box_tid_type("Almighty"))
			return bobox::box_model_ptr_type(new almighty_box::model(id, tid, this));
		if (tid == bobox::box_tid_type("Source"))
			return bobox::box_model_ptr_type(new source_box::model(id, tid, this));
		if (tid == bobox::box_tid_type("Destination"))
			return bobox::box_model_ptr_type(new destination_box::model(id, tid, this));
		assert(false);
	}

	virtual bobox::type_descriptor_ptr_type create_type_descriptor_impl(bobox::type_tid_type tid, 
        const bobox::parameters &params)
	{
		if (tid == bobox::type_tid_type("int"))
			return bobox::type_descriptor_ptr_type(new bobox::generic_type_descriptor<bobox::int_policy>());
		if (tid == bobox::type_tid_type("string"))
			return bobox::type_descriptor_ptr_type(new bobox::generic_type_descriptor<bobox::string_policy>());
		assert(false);
	}
};

#endif
